package com.service;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.entity.IndexWall;
import com.entity.News;
import com.entity.Wall;
import com.mapper.WallMapper;

@Service
public class WallService {
	@Autowired
	private WallMapper wallMapper;
	
	/* 添加表白墙 */
	public void installWall(Wall wall) {
		this.wallMapper.installWall(wall);
	}
	
	/* 删除表白墙 */
	public void deleteWall(Wall wall) {
		this.wallMapper.deleteWall(wall);
	}
	
	/* 查找二十条表白墙 分页 */
	public ArrayList<IndexWall> foundWalls(String userid){
		return this.wallMapper.foundWalls(userid);
	}
	
	/* 查找1条表白墙 通过wallid */
	public Wall foundWallBywallid(String wallid) {
		return this.wallMapper.foundWallBywallid(wallid);
	}
	/* 首页展示三条最新表白信息 */
	public ArrayList<IndexWall> foundWalltoindex() {
		return this.wallMapper.foundWalltoindex();
	}
	/*分页展示公告信息*/
    public List<Wall> queryAllWalls(@Param("page") Integer page, @Param("count") Integer count){
    	
    	List<Wall> walls=wallMapper.queryAllWalls(page,count);
		/*
		 * Iterator iter = walls.iterator();
		 * 
		 * while(iter.hasNext()){ Wall o = (Wall) iter.next();
		 * System.out.println(o.toString()); }
		 */return walls;
    }
    /* 总的条数 */
    public Integer LookWallCount() {
    	return wallMapper.LookWallCount();
    }
}
